/**
 @Name: 用户模块
 */
 
layui.define(['element', 'laypage', 'fly', 'upload'], function(exports) {
	var $ = layui.jquery;
	var element = layui.element();
	var laypage = layui.laypage;
	var fly = layui.fly;
	var upload = layui.upload;
	var avatarAdd = $('.avatar-add');
	upload({
		url: '/user/modifyAvatar'
		,elem: '#avatarImg' //指定原始元素，默认直接查找class="layui-upload-file"
		,method: 'post' //上传接口的http类型
	    ,before: function(){
	    	avatarAdd.find('.loading').show();
	    }
		,success: function(res){
			if(res && res.code == 1) {
				$("#avatarImage").attr("src", res.msg);
			} else {
				layer.msg(res.msg, {icon: 5});
			}
			avatarAdd.find('.loading').hide();
		}
	});
	
	var vcImg = function(){
		$("#vcImg").attr("src", "/vc?"+new Date().getTime());
	};
	var vc = function(){
		$("#vcImgDiv").html('<img src="/vc?'+new Date().getTime()+'" id="vcImg">');
		$("#vcImg").click(vcImg);
	};
	$("#vercode").focus(vc);
	
  
	exports('user', null);
});
